1. Field of the Invention
The present invention relates to an image processing apparatus and image processing method and, more particularly, to an image processing apparatus and image processing method for performing error diffusion processing for an image.
2. Description of the Related Art
It is a common practice to process an image captured by a digital camera or the like and print the processed image. However, the printing apparatus can express a smaller number of tones per pixel than by the display apparatus. Pseudo-halftone processing is therefore required to reduce the number of tones of an image before printing and pseudo-expressing the original tonality. Pseudo-halftone processing is achieved by various methods. Among them, error diffusion processing is most popular because it can provide an image that satisfies both tonality and resolution. Error diffusion processing sequentially executes processing to diffuse the difference (quantization error) between the tone value of the pixel of interest and the quantization value of the pixel of interest to unprocessed pixels around the pixel of interest at predetermined ratios.
When processing image data, it needs to be developed in the memory. However, the cost rises if the device is equipped with a memory having a full-size storage capacity capable of developing all image data corresponding to one image. It is not practical to mount such a memory having a full-size storage capacity in a device which needs to be provided at low cost, like a home printer. Under the circumstances, an image is generally divided into a plurality of regions, and the regions are developed one by one in the memory and undergo image processing.
However, when error diffusion processing is done after region division, a dot pattern mismatch occurs at a joint where the error diffusion processing results of regions are connected. This is visually recognized as thread-like image degradation. This is because no error is diffused between regions, impairing the continuity of error diffusion processing at the joint.
Japanese Patent Publication No. 6-091606 (Japanese Patent Laid-Open No. 63-310269) discloses an invention which buffers a quantization error generated upon quantizing a pixel at the boundary of the region of interest in order to use it for error diffusion processing for a pixel at the boundary of a region to be processed next (to be referred to as the next region). Further, this literature discloses an invention which sets an overlapping region between the region of interest and the next region to approximate a quantization error to be diffused from a pixel at the boundary of the region of interest to one at the boundary of the next region.
In an invention disclosed in Japanese Patent No. 3004628, an image is divided into bands in the sub-scanning direction, and each band is further divided into slices in the main scanning direction. A quantization error generated in the final pixel of the slice is stored in the first memory, and a quantization error generated in each pixel is stored in the second memory. The first pixel of each slice is quantized by referring to quantization errors stored in the first and second memories. Another pixel is quantized by referring to only quantization errors stored in the second memory. Then, error diffusion processing is done. Error spread between bands using two memories which buffer quantization errors simultaneously achieves reduction of the storage capacity of the memory for developing an image and maintenance of the continuity of error diffusion processing at the band boundary.
The above-described conventional technique buffers a quantization error at the boundary of a region having undergone error diffusion processing (to be referred to as a previous region) before the region of interest. However, the continuity of error diffusion processing cannot always be maintained depending on the error diffusion processing method. For example, a quantization error itself may be buffered, or a diffusion error to be diffused to each pixel may be buffered. The diffusion error is a value obtained by multiplying the quantization error of the pixel of interest by a diffusion coefficient determined by the relationship between the pixel of interest and a pixel at the error diffusion destination (to be referred to as a diffusion destination pixel), and integrating the resultant values for each diffusion destination pixel. A method of storing an error in the buffer memory and a method of referring to an error stored in the buffer memory differ between these two cases. If the processing results of respective regions are connected without properly storing and referring to a buffered error (to be referred to as a spread error), a discontinuous dot pattern is generated at the joint.
In addition, a pixel whose quantization error is spread and a pixel to which a diffusion error is spread change depending on the region division manner such as whether to set an overlapping region or whether divided regions partially overlap each other. Note that divided regions partially overlap each other when an image is formed by superposing the dot patterns of adjacent divided regions. For example, even if an overlapping region is set and an error is spread from the boundary at the lower end of the region of interest to the next region, a discontinuous dot pattern may appear at the joint. This is because a portion where an error needs to be spread between regions does not coincide with the boundary at the lower end of the region of interest and the continuity of error diffusion processing is lost. When divided regions partially overlap each other, the lower end of the region of interest is not the boundary of the next region to which an error needs to be spread. Thus, no error can be appropriately spread, generating a discontinuous dot pattern at the joint.